package servletTestOne;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Post extends HttpServlet {
	private String message ;

	@Override
	public void init(ServletConfig config) throws ServletException {
		System.out.println("servlet初始化.......");
		super.init(config);
	}

//	@Override
//	protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
//		System.out.println("Get");
//		String userName = req.getParameter("userName");
//		String password = req.getParameter("password");
//		System.out.println(userName);
//		System.out.println(password);
//		response.setContentType("text/html");
//		PrintWriter writer = response.getWriter();
//		writer.write("<h2>userName" + userName + "<h2>userName");
//		writer.write("<h2>password" + password + "<h2>password");
//
//	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String name = req.getParameter("name");
		String age = req.getParameter("age");
		req.getRequestDispatcher("one.html").forward(req, resp);
	}

	@Override
	public void destroy() {
		System.out.println("servlet销毁.......");
		super.destroy();
	}

}
